#ifndef YASAIWORKER_H
#define YASAIWORKER_H

#include <QtConcurrent/QtConcurrentRun>
#include <QFuture>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QPixmap>
#include <QRect>
#include <QByteArray>
#include "lib7ziparchivehandler.h"
#include "utils.h"
// #include "opencv2/opencv.hpp"

class YasaiWorker : public QObject
{
    Q_OBJECT

public:
    YasaiWorker(int scrollbarWidth, QObject *parent = 0);
    virtual ~YasaiWorker();

public slots:
    void on_started();
    void on_finished();
    void openFile(const QFileInfo &fileInfo, const QString &place, const QRect &viewRect, Utils::ViewOptions viewOptions, int adjustment);
    void loadArchiveImage(int pos, int nextPos, const QRect &viewRect, Utils::ViewOptions viewOptions, int adjustment);

signals:
    void archiveLoaded(QStandardItemModel *model, const QString &place);
    void showImage(const QPixmap &pixmap);
    void showTwoImages(const QPixmap &current, const QPixmap &next);
    void detectedWidePages(int widePos, int nextWidePos);
    void workerBusy(const QString &message);
    void workerDone();

private:
    const int mScrollbarWidth;
    QPixmap fitPixmap(const QPixmap &pixmap, const QRect &viewRect, Utils::ViewOptions viewOptions, int adjustment);
    QPixmap loadAndFitPixmap(QByteArray *qba, const QRect &viewRect, Utils::ViewOptions viewOptions, int adjustment);
    Lib7zipArchiveHandler *mArchiveFileHandler;
};

#endif // YASAIWORKER_H

